package com.cos.controller.jpushcontroller;



import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.cos.controller.base.BaseController;
import com.cos.service.jpush.PushMessage;
import com.cos.util.PageData;
import com.cos.util.ResponseUtil;
/**
 * 
 * TODO 类或接口说明
 * <p/>
 * 
 * @author <a href="mailto:Hoindbq@163.com">YANG</a>
 * @version  Date: 2016年3月26日 上午11:30:30
 * @serial 1.0
 * @since 2016年3月26日 上午11:30:30
 */
@Controller
@RequestMapping(value="/appuser")
public class JpushController extends BaseController{
	@Resource
	private PushMessage jpushService  ;
	
	/**
	 * 发送广播
	 * @throws Exception 
	 /*
	  * @param response
	  * @return
	  * @throws Exception
	  */
	@RequestMapping(value="pushMessage")
	@ResponseBody
	public /*ModelAndView */ void pushMsgToAllUser(HttpServletResponse response) throws Exception{
		logBefore(logger, "向所有用户推送广播");
		//JsonArray json = new JsonArray() ;
		ModelAndView mv = this.getModelAndView();
		PageData pd = new PageData();
		pd = this.getPageData();
		pd.put("ID", get32UUID());
		//pd.put("PUSH_CONTENT",pd.getString("PUSH_CONTENT"));
		//pd.put("TITLE",pd.getString("TITLE"));
		//pd.put("DEVICETOKEN",pd.getString("DEVICETOKEN")) ;
		//mv.addObject("msg","success");
		//mv.setViewName("save_result");
		String result = jpushService.pushMsgBroadCast(pd) ;
		if(result!=null){
			
			ResponseUtil.write(response, result);
		}
		//return mv;
	}
	
	
	
}
